package com.itheima.variable;

import java.util.Random;
import java.util.Scanner;

/**
 * @author yuanying
 * @date 2025/7/22 -  11:21
 */
public class RandomDemo2 {
    public static void main(String[] args) {
        Random r=new Random();
        int luckNumber=r.nextInt(100)+1;

        Scanner sc=new Scanner(System.in);
        while (true) {
            System.out.println("请输入您预测的数字：");
            int guessNumber = sc.nextInt();
            if(guessNumber>luckNumber){
                System.out.println("猜大了");
            }else if(guessNumber<luckNumber){
                System.out.println("猜小了");
            }else {
                System.out.println("恭喜您，猜对了，去买单吧！");
                break;
            }

        }

    }
}
